package com.chenchao.method;

import java.util.function.Function;

/**
 * @encoding : UTF-8
 * @Time : 2020/12/4 18:40
 * @Author : Chen Chao
 * @File : javaSE.com.chenchao.method.Test08.java
 * @Software : IntelliJ IDEA
 * @since : 1.8
 * 
 */
public class Test08 {
    public static void main(String[] args) {

    }
    public static void test01(){
        String s = "林青霞,30";
        String string=test01(s,
                s1 -> Integer.parseInt(s1.split(",")[1]),
                integer -> "5年后，林老师"+(integer+5)+"岁");
        System.out.println(string);
    }
    public static void test02(){
        String s = "林青霞,30";
        String string=test02(s,
                s1 ->s1.split(",")[1],
                Integer::parseInt,
                integer -> "5年后，林老师"+integer+"岁");
        System.out.println(string);
    }
    public static String test02(String str, Function<String,String> f1,
                                Function<String,Integer> f2,Function<Integer,String> f3){
        /*前一个的输出是后一个的输入*/
        return f1.andThen(f2).andThen(f3).apply(str);
    }
    public static String test01(String str, Function<String,Integer> f1,
                                Function<Integer,String> f2){
        /*前一个的输出是后一个的输入*/
        return f1.andThen(f2).apply(str);
    }
}
